package ganga.custodian;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Service running after boot time
 * @author Apocrypha
 *
 */
public class CustodianService extends Service {
	private CustodianApplication application;
	private Timer updateTimer;
	private TimerTask doRefresh = new TimerTask() {
	    public void run() {
	        refreshChartData();
	      }
	};

	@Override
	public void onCreate() {
		super.onCreate();
		application =  CustodianApplication.getInstance();
	    updateTimer = new Timer("ChartDataUpdates");
	    application.showToast("CustodianService create");
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		long updatePeriod = 1 *60*1000;
		// super.onStartCommand(intent, flags, startId);
		updateTimer.schedule(doRefresh, 0, updatePeriod);
		return Service.START_STICKY;
	}

	@Override
	public IBinder onBind(Intent arg0) {
		return null;
	}

	private void refreshChartData() {
		// TODO
	}
}
